<template>
	<!-- <img src="/static/bg.png" alt="" class="bg"/> -->
	<view class="box">
		<Meslist></Meslist>
	</view>
</template>

<script>
	import Meslist from "@/modul/Home/messagelist.vue"
	import {
		getMypost,
		getchatHistroyUser,
		getothermessage
	} from '@/store/api.js'
	export default {
		onPageScroll({ scrollTop }) {
		    console.log('监听页面滚动');
		
		    if (scrollTop === 0) console.log('页面触顶');
		},
		onLoad() {
			uni.setStorageSync('AlreadyConnect', false)
		},
		mounted() {
			let token = uni.getStorageSync('a_tk')
			if (!uni.getStorageSync('chat_History_page')) {
				let chatPage = []
				getchatHistroyUser().then(res => {
					console.log('聊天对象')
					console.log(res)
					res.data.data.forEach(item => {
						if (chatPage.find(it => item.userid == it.userid)) {} else {
							chatPage.unshift({
								name: item.userName,
								src: item.avatar,
								userid: item.id,
								content: '',
								time: '',
								new: false
							})
						}
					})
					// let token = uni.getStorageSync('a_tk')
					// setTimeout(()=>{
					uni.setStorageSync('chat_History_page', chatPage)
					// },2000)

					// setTimeout(() => {
					// 	uni.connectSocket({
					// 		url: `wss://meet.ysyxmy.top/web/socket?access_token=${token}`,
					// 	});
					// },1000)
				})
			}
		},
		components: {
			Meslist,
		},
		data() {
			return {

			};
		}
	}
</script>

<style lang="scss" scoped>
	// .box {
	// 	position: relative;
	// 	z-index: 2;
	// }
</style>